/**
 * 手机版页面app
 * Created by yangyan on 2015/6/7 .
 */
// Initialize app
var myApp = new Framework7({
    pushState:true,
    swipePanel:'left',
    modalTitle:'提示',
    modalButtonOk:'好',
    modalButtonCancel:'取消',
    modalPreloaderTitle:'加载中...',
    modalUsernamePlaceholder:'用户名',
    modalPasswordPlaceholder:'密码',
    scrollTopOnNavbarClick:true,
    //imagesLazyLoadPlaceholder:''
    // Hide and show indicator during ajax requests
    onAjaxStart: function (xhr) {
        myApp.showIndicator();
    },
    onAjaxComplete: function (xhr) {
        myApp.hideIndicator();
    }
    //,preroute: function (view, options) {
    //    if (!userLoggedIn) {
    //        view.router.loadPage('login.do'); //load another page with auth form
    //        return false; //required to prevent default router action
    //    }
    //}
});

// If we need to use custom DOM library, let's save it to $$ variable:
var $$ = Dom7;

// Add view
var mainView = myApp.addView('.view-main', {
    // Because we want to use dynamic navbar, we need to enable it for this view:
    dynamicNavbar: true
});

var rightView = myApp.addView('.right-view', {
    // Because we want to use dynamic navbar, we need to enable it for this view:
    dynamicNavbar: true
});

// Now we need to run the code that will be executed only for About page.

// Option 1. Using page callback for page (for "about" page in this case) (recommended way):
myApp.onPageInit('about', function (page) {
    // Do something here for "about" page
    myApp.alert('1 Here comes About page');
})
/*

// Option 2. Using one 'pageInit' event handler for all pages:
$$(document).on('pageInit', function (e) {
    // Get page data from event data
    var page = e.detail.page;

    if (page.name === 'about') {
        // Following code will be executed for page with data-page attribute equal to "about"
        myApp.alert('2 Here comes About page');
    }
})

// Option 2. Using live 'pageInit' event handlers for each page
$$(document).on('pageInit', '.page[data-page="about"]', function (e) {
    // Following code will be executed for page with data-page attribute equal to "about"
    myApp.alert('3 Here comes About page');
})*/
